package com.lzh.common.utils;

import org.apache.tomcat.util.codec.binary.Base64;

public class Base64Util {

	//base64 解码
    public static String decode(byte[] bytes) {  
        return new String(Base64.decodeBase64(bytes));
    }  
  
    //base64 编码
    public static String encode(byte[] bytes) {  
        return new String(Base64.encodeBase64(bytes));  
    }

	public static void main(String[] args) {
		String string = "黑马头条";
		//编码
		String encode = encode(string.getBytes());
		System.out.println("编码后：" + encode);
		//解码
		String decode = decode(encode.getBytes());
		System.out.println("解码后：" + decode);
	}
}